package com.example.springdemo.redis.jedis;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

/**
 * redis客户端Jedis练习
 */
@Component
public class JedisDemo {
    Jedis jedis = new Jedis("127.0.0.1",6379);

    public String getValue(){
        try {
//            jedis.auth("zd981612");
            jedis.set("zhang", "haoshuai");
            return jedis.get("zhang");
        }catch (Exception E){
            E.printStackTrace();
            return "error";
        }finally {
            jedis.disconnect();
        }
    }

}
